//
//  AHNetWork.m
//  安好
//
//  Created by rlp on 14-11-24.
//  Copyright (c) 2014年 lianchuangbrother. All rights reserved.
//

#import "AHNetWork.h"
@implementation AHNetWork
- (void)downLoadForURL:(NSString *)url parameters:(NSDictionary *)parameters showData:(void(^)(NSDictionary *jsonData))showData error:(void(^)(NSError *error))errorData
{
    
//       NSURL *useurl = [NSURL URLWithString:url];
//    NSURLRequest *request = [NSURLRequest requestWithURL:useurl];
    
    
    
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager POST:url parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error=nil;
        NSData *data = [responseObject dataUsingEncoding:NSUTF8StringEncoding];
         NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
        NSLog(@"JSON: %@", responseObject);
        _showData((NSDictionary*)responseObject);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Error: %@", error);
        _errorData((NSError*)error);

    }];
    

}

@end
